<?php
class ActvipcardModel extends Model {
	
	/**
	 * 
	 * @param  $userid int 会员编号
	 * @return $json
	 */
	public function getUserVipDetail($userid){
		
		$map['userid'] = $userid;
		$json          = sendRest("Vip/view",$map);
	
		//会员卡二维码
		$json['data']['erweima'] = erweima(HTTP_URL.REL_URL."hdmin.php?s=/Vipcard/content/id/".$json['data']['cid']);
		
		//会员特权
		$json['data']['list']   = explode("\n",$json['data']['privileged']);
		
		return $json;
	} 
	
	/**
	 * 获取用户会员卡积分操作记录
	 * @param $userid int 用户id
	 */
	public function getUserVipCredit($map){
		
		$json = sendRest("Vip/credit",$map);
	
		$map['fields'] = "jifen_rule";
		$card = sendRest("Vip/view",array("userid"=>$map['userid']));
	
		$json['list'] = explode("\n",$card['data']['jifen_rule']);
		return $json;
	}
	
	/**
	 * 获取用户会员卡金额操作记录
	 * @param  $userid  int 会员id
	 * @return $json 数组
	 */
	public function getUserVipMoney($map){

		$json = sendRest("Vip/money",$map);
	
		$map['fields'] = "money_rule";
		$card = sendRest("Vip/view",array("userid"=>$map['userid']));
	
		$json['list'] = explode("\n",$card['data']['money_rule']);
		return $json;
	}
	
	public function getVipInstruction($userid){
		$map['fields'] = "instruction";
		$map['userid'] = $userid;
		$json = sendRest("Vip/view",$map);
		
		$list = explode("\n",$json['data']['instruction']);
		return $list;
	}
}
?>